#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int arr[N];
int visited[N];
int parent[N];
int n;
bool Prime(int n)
{
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}
void dfs(int u, int count)
{
	count++;
	//if (count == n) {
	//	if (Prime(arr[u] + arr[0])) {
	//		parent[count - 1] = arr[u];
	//	}
	//	for (int i = 0; i < n; i++) {
	//		cout << parent[i] << " ";
	//	}
	//	cout << endl;
	//	return;
	//}
	if (count == n && Prime(arr[u] + arr[0])) {
		parent[count - 1] = arr[u];
		for (int i = 0; i < n; i++) {
			cout << parent[i] << " ";
		}
		cout << endl;
	}
	visited[u] = 1;
	for (int i = 0; i < n; i++) {
		if (visited[i]==0&&Prime(arr[i] + arr[u])){
			parent[count - 1] = arr[u];
			//count++;
			dfs(i, count);
			visited[i] = 0;
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		arr[i] = i + 1;
	}
	int count = 0;
	dfs(0, count);
	return 0;
}